/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */

package br.ufmg.dees.insane.xyplot.xyplot_view;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

import br.ufmg.dees.insane.commons.view.ViewState;

/**
 * A class representing the state of the model.
 * @author  	Penna, Samuel & Pitangueira, Roque
 * @see xyplot_view.InterfaceXYPlot
 * @see xyplot_view.DrawingArea
 * @since    april 2005
 */
public class XYPlotViewState extends ViewState implements Serializable {

    
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;
	
	//private String title;
	private TitleViewState titleViewState = new TitleViewState();
	private AxisViewState  xAxisViewState = new AxisViewState();
	private CaptionState captionState = new CaptionState();
	private TextBoxState textBoxState = new TextBoxState();
	private AxisViewState  yAxisViewState = new AxisViewState();
	public 	ArrayList<AxisViewState> axisView = new ArrayList<AxisViewState>();
	public 	ArrayList<SequenceViewState> sequencesView = new ArrayList<SequenceViewState>();
    
    /**
     * The class constructor 
     */
    public XYPlotViewState() {   
    	axisView.add(xAxisViewState);
    	axisView.add(yAxisViewState);
    	
    }
//***************************************************************************************    
 
    /**
	 * @return  Returns the titleViewState.
	 * @uml.property  name="titleViewState"
	 */
    public TitleViewState getTitleViewState(){
        return this.titleViewState;
    }
    
//***************************************************************************************
    
    /**
	 * @return  Returns the xAxisViewState.
	 * @uml.property  name="xAxisViewState"
	 */
    public AxisViewState getXAxisViewState(){
        return (AxisViewState)this.axisView.get(0);
    }
  
	/**
	 * @return  Returns the captionState.
	 * @uml.property  name="captionState"
	 */
	public CaptionState getCaptionState() {
		return captionState;
	}
	/**
	 * @param captionState  The captionState to set.
	 * @uml.property  name="captionState"
	 */
	public void setCaptionState(CaptionState captionState) {
		this.captionState = captionState;
	}
//***************************************************************************************
    
    /**
	 * @return  Returns the yAxisViewState.
	 * @uml.property  name="yAxisViewState"
	 */
    public AxisViewState getYAxisViewState(){
        return (AxisViewState)this.axisView.get(1);
    }
//  ***************************************************************************************
    
    public AxisViewState getAxisState(int i){
        return (AxisViewState)this.axisView.get(i);
    }
//***************************************************************************************
    
    public SequenceViewState getSequenceState(int i){
        return (SequenceViewState)this.sequencesView.get(i);
    }

//***************************************************************************************    
    
    /**
	 * @param titleViewState  The titleViewState to set.
	 * @uml.property  name="titleViewState"
	 */
    public void setTitleViewState(TitleViewState tvs){
        this.titleViewState = tvs;
    }
    
//***************************************************************************************
    
    /**
	 * @param xAxisViewState  The xAxisViewState to set.
	 * @uml.property  name="xAxisViewState"
	 */
    public void setXAxisViewState(AxisViewState xvs){
        this.xAxisViewState = xvs;
        this.axisView.remove(0);
        this.axisView.add(0,xvs);
    }

//***************************************************************************************
    
    /**
	 * @param yAxisViewState  The yAxisViewState to set.
	 * @uml.property  name="yAxisViewState"
	 */
    public void setYAxisViewState(AxisViewState yvs){
        this.yAxisViewState = yvs;
        this.axisView.remove(1);
        this.axisView.add(1,yvs);
    }

//***************************************************************************************    
    
    public void addAxisState(AxisViewState axvs){
        this.axisView.add(axvs);
    }
 
    /** Add a axis view state in specifeid positon axisView list.
     *  @param svs The axis view state which will be add.
     *  @param index The position of the axis which will be add the view state.
     */
    public void add(int index ,AxisViewState axvs){    
        this.axisView.add(index,axvs);
    }
    
//***************************************************************************************    

    /** Returns the list of axis view states.
     *  @return The list of axis view states.
     */
    public List<AxisViewState> getAxisViewList() {
        return axisView;
    }

    /** Sets the list of axis view states.
     *  @param svs The list of axis view states.
     */
    public void setAxisViewList(ArrayList<AxisViewState> axvs) {
        axisView = axvs;
    }

//******************************************************************************
    
    /** Returns the number of axis view states.
     *  @return The number of axis view states.
     */
    public int getNumberOfAxisViewStates(){
    return (axisView.size());
    }
    
//   *****************************************************************************

    /** Remove a axis view state of this Sequence.
     *  @param axvs The axis view state which will be removed.
     */ 
    public void remove(AxisViewState axvs){
        AxisViewState vs;
    ListIterator axsState = axisView.listIterator();
    while (axsState.hasNext()) {
        vs = (AxisViewState)axsState.next();
        if (vs.equals(axvs)){
            axsState.remove();
        }
    }
    }

//   ******************************************************************************

    /** Remove a axisView at the specified position of this list.
     *  @param index The position of the axisView which will be removed.
     */ 
    public void removeAxisView(int index) {
        sequencesView.remove(index);
    }

//   *****************************************************************************

    /** Sets the SequenceViewState at the specified position in this list.
     *  @param index The SequenceViewState of the point which will be set.
     *  @param svs The SequenceViewState of this list.
     */
    public void setAxisViewState(int index, AxisViewState axvs) {
       axisView.set(index, axvs);
    }

//   *****************************************************************************

    /** Returns the position of a specified SequenceViewState in this list.
     *  @param ss The SequenceViewState.
     */
    public int indexOf(AxisViewState axs) {
        int index = -1;
        AxisViewState st;
        ListIterator ist = axisView.listIterator();
        while (ist.hasNext()) {
            st = (AxisViewState)ist.next();
            if (st.equals(axs)){
                index = axisView.indexOf(st);
            }
        }
    return index;
    }
    
//   *****************************************************************************
    
    /** Remove all axis from this list.*/ 
    public void clearAxis() {
        axisView.clear();
    }
  
//***************************************************************************************    
    
    public void addSequenceState(SequenceViewState svs){
        this.sequencesView.add(svs);
    }
 
    /** Add a sequence view state in specifeid positon sequenceView list.
     *  @param svs The sequence view state which will be add.
     *  @param index The position of the sequence which will be add the view state.
     */
    public void add(int index ,SequenceViewState svs){    
        this.sequencesView.add(index,svs);
    }
    
//***************************************************************************************    

    /** Returns the list of sequences view states.
     *  @return The list of sequence view states.
     */
    public List<SequenceViewState> getSequencesViewList() {
        return sequencesView;
    }

    /** Sets the list of sequences view states.
     *  @param svs The list of sequences view states.
     */
    public void setSequencesViewList(ArrayList<SequenceViewState> svs) {
        sequencesView = svs;
    }

    //******************************************************************************
    
    /** Returns the number of sequences view states.
     *  @return The number of sequence view states.
     */
    public int getNumberOfSequencesViewStates(){
    return (sequencesView.size());
    }
    
//   *****************************************************************************

    /** Remove a sequence view state of this Sequence.
     *  @param svs The sequence view state which will be removed.
     */ 
    public void remove(SequenceViewState svs){
    	SequenceViewState vs;
    	ListIterator seqState = sequencesView.listIterator();
    	while (seqState.hasNext()) {
    		vs = (SequenceViewState)seqState.next();
    		if (vs.equals(svs)){
    			seqState.remove();
    		}
    	}
    }

//   ******************************************************************************

    /** Remove a sequenceViewState at the specified position of this list.
     *  @param index The position of the sequenceViewState which will be removed.
     */ 
    public void remove(int index) {
        sequencesView.remove(index);
    }

//   *****************************************************************************

    /** Sets the SequenceViewState at the specified position in this list.
     *  @param index The SequenceViewState of the point which will be set.
     *  @param svs The SequenceViewState of this list.
     */
    public void setSequenceViewState(int index, SequenceViewState svs) {
        sequencesView.set(index, svs);
    }

//   *****************************************************************************

    /** Returns the position of a specified SequenceViewState in this list.
     *  @param ss The SequenceViewState.
     */
    public int indexOf(SequenceViewState ss) {
        int index = -1;
        SequenceViewState st;
        ListIterator ist = sequencesView.listIterator();
        while (ist.hasNext()) {
            st = (SequenceViewState)ist.next();
            if (st.equals(ss)){
                index = sequencesView.indexOf(st);
            }
        }
    return index;
    }
    
//   *****************************************************************************
    
    /** Remove all sequences from this list.*/ 
    public void clearSequences() {
        sequencesView.clear();
    }
//   *****************************************************************************   
    
    
    
	/**
	 * @return  Returns the textBoxState.
	 * @uml.property  name="textBoxState"
	 */
	public TextBoxState getTextBoxState() {
		return textBoxState;
	}
	/**
	 * @param textBoxState  The textBoxState to set.
	 * @uml.property  name="textBoxState"
	 */
	public void setTextBoxState(TextBoxState textBoxState) {
		this.textBoxState = textBoxState;
	}
	
//  *****************************************************************************   
}